﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TaxMaster.aspx.cs" Inherits="Main_TaxMaster"
    EnableEventValidation="false" Culture="en-GB" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="AjaxControl" %>
<%@ Register Src="~/User Controls/PageHeading.ascx" TagName="heading" TagPrefix="acc" %>
<%@ Register Src="~/User Controls/CommonControls.ascx" TagName="CommonControls" TagPrefix="MyControls" %>
<%@ Register Src="~/User Controls/Pager.ascx" TagPrefix="custom" TagName="Pager" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Tax Master</title>
    <link href="../../Styles/accounts.css" rel="stylesheet" type="text/css" />
    <script src="../../Menu/js/jquery.min.js" type="text/javascript"></script>
    <link href="../../Styles/HorizontalTab.css" rel="stylesheet" type="text/css" />
    <script src="../../JavaScript/HorizontalTab.js" type="text/javascript"></script>
    <script type="text/javascript">
        function isNumberKey(control_id, evt) {
            var charCode = (evt.which) ? evt.which : event.keyCode
            if (charCode > 31 && (charCode < 48 || charCode > 57) && (charCode < 45 || charCode > 47))
                return false;

            if (charCode == 46) {
                var dotcount = document.getElementById(control_id).value.split('.').length - 1;
                if (dotcount >= 1) {
                    return false;
                }
            }
            return true;
        }
        function ValidateInput() {
            var flag = true;
            if (document.getElementById("ddlTaxType").value == '0') {
                alert('Specify Tax Type');
                flag = false;
                document.getElementById("ddlTaxType").focus();

            }
            else if (document.getElementById("ddlMainClass").value == '0') {
                alert('Specify Tax Main Class');
                flag = false;
                document.getElementById("ddlMainClass").focus();

            }
            else if (document.getElementById("ddlSubClass").value == '0') {
                alert('Specify Tax Sub Class');
                flag = false;
                document.getElementById("ddlSubClass").focus();

            }
            else if (document.getElementById("txtTaxRate").value == '') {
                alert('Specify Tax Rate');
                flag = false;
                document.getElementById("txtTaxRate").focus();

            }
            else if (document.getElementById("txtFromDate").value == '') {
                alert('Specify Effective From Date');
                flag = false;
                document.getElementById("txtFromDate").focus();

            }
            return flag;
        }
        function CheckValidateAddTaxLedger() {
            var table = document.getElementById("grdAdditionalTax");
            var tableRow = table.getElementsByTagName("tr");
            for (var i = 0; i < tableRow.length; i++) {
                var chkBox;
                var textBox;
                var inputs = tableRow[i].getElementsByTagName("input")
                for (var j = 0; j < inputs.length; j++) {
                    if (inputs[j].type == "checkbox") {
                        chkBox = inputs[j];
                    }
                    if (inputs[j].type == "text") {
                        textBox = inputs[j];
                    }
                }
                if (chkBox.checked == true) {
                    if (textBox.value == '') {
                        alert("rate");
                    }
                }

            }

            return false;
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div class="divmain">
        <acc:heading ID="pagehead" runat="server" HeadingText="Tax Master" />
    </div>
    <asp:UpdateProgress DynamicLayout="false" ID="UpdProgress" runat="server">
        <ProgressTemplate>
            <div align="center" style="margin-bottom: 5px;">
                <img src="../../Images/ajax-loader.gif" /></div>
        </ProgressTemplate>
    </asp:UpdateProgress>
    <div style="text-align: center;">
        <asp:Label ID="lblMsg" runat="server"> </asp:Label>
    </div>
    <asp:HiddenField ID="hidTaxDetId" runat="server" Value="0" />
    <asp:HiddenField ID="hidTaxMasterId" runat="server" Value="0" />
    <table class="tablecontent" style="width: 90%; margin-left: 5%; margin-right: 5%;">
        <tr>
            <td class="headtd" colspan="4">
                Tax Details
            </td>
        </tr>
        <tr>
            <td>
                Tax Type <span style="color: Red;">*</span>
            </td>
            <td>
                <asp:DropDownList ID="ddlTaxType" runat="server" AutoPostBack="true" CssClass="dropdown"
                    Width="160px" OnSelectedIndexChanged="ddlTaxType_SelectedIndexChanged">
                </asp:DropDownList>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="ddlTaxType"
                    ErrorMessage="*" ValidationGroup="tax"></asp:RequiredFieldValidator>
            </td>
            <td>
                Main Class <span style="color: Red;">*</span>
            </td>
            <td>
                <asp:DropDownList runat="server" ID="ddlMainClass" Enabled="false" Width="160px"
                    CssClass="dropdown" AutoPostBack="True" OnSelectedIndexChanged="ddlMainClass_SelectedIndexChanged">
                </asp:DropDownList>
            </td>
        </tr>
        <tr>
            <td>
                Sub Class <span style="color: Red;">*</span>
            </td>
            <td>
                <asp:DropDownList runat="server" ID="ddlSubClass" Enabled="false" CssClass="dropdown"
                    AutoPostBack="true" OnSelectedIndexChanged="ddlSubClass_SelectedIndexChanged"
                    Width="160px" />
            </td>
            <td>
                Short Name <span style="color: Red;">*</span>
            </td>
            <td>
                <asp:DropDownList runat="server" ID="ddlShortName" Enabled="false" CssClass="dropdown"
                    Width="160px" AutoPostBack="True" />
            </td>
        </tr>
    </table>
    <div id="wrapper">
        <ul class="tabs">
            <li><a href="javascript:void(0)" class="defaulttab" rel="tabbasicdetails">Basic Details</a></li>
            <li><a href="javascript:void(0)" rel="tabCenVat" id="hyperTDS" runat="server">TDS/TCS/Services/CENVAT
                Tax Details</a></li>
        </ul>
        <div class="tab-content" id="tabbasicdetails" runat="server">
            <div style="margin-left: 10px;">
                <table style="width: 100%">
                    <tr>
                        <td colspan="6">
                            <b>Tax Effective Period:</b>
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 15%;">
                            From Date<span style="color: Red;">*</span>
                        </td>
                        <td style="width: 25%;">
                            <asp:TextBox ID="txtFromDate" CssClass="input" ValidationGroup="V" Width="90px" runat="server"></asp:TextBox>
                            <asp:ImageButton ID="imgFromDate" runat="server" ImageUrl="~/Images/calendar.gif" />
                            <AjaxControl:CalendarExtender ID="calFromDate" runat="server" TargetControlID="txtFromDate"
                                PopupButtonID="imgFromDate" Format="dd/MM/yyyy" Enabled="True">
                            </AjaxControl:CalendarExtender>
                            <AjaxControl:MaskedEditExtender ID="maskFromDate" runat="server" TargetControlID="txtFromDate"
                                MaskType="Date" Mask="99/99/9999">
                            </AjaxControl:MaskedEditExtender>
                            <AjaxControl:MaskedEditValidator ID="maskValFromDate" runat="server" ValidationGroup="V"
                                ControlExtender="maskFromDate" ControlToValidate="txtFromDate" InvalidValueMessage="Invalid"></AjaxControl:MaskedEditValidator>
                        </td>
                        <td style="width: 15%;">
                            To Date
                        </td>
                        <td style="width: 15%;">
                            <asp:TextBox ID="txtToDate" CssClass="input" runat="server" Width="90px" Text="Till Date"
                                Enabled="False"></asp:TextBox>
                        </td>
                        <td style="width: 15%;">
                            Tax Rate(%)<span style="color: Red;">*</span>
                        </td>
                        <td style="width: 15%;">
                            <asp:TextBox ID="txtTaxRate" runat="server" Width="90px" CssClass="inputnumber" onkeypress="return isNumberKey(this.id,event);"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="6" style="margin-top: 5px; margin-bottom: 5px;">
                            <b>Tax Effective Period:</b>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Ledger <span style="color: Red;">*</span>
                        </td>
                        <td colspan="5">
                            <asp:DropDownList runat="server" CssClass="dropdown" ID="ddlTaxLedger" Width="300px">
                            </asp:DropDownList>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        <div class="tab-content" id="tabCenVat" runat="server">
            <div style="margin-left: 10px;">
                <table style="width: 100%">
                    <tr>
                        <td style="width: 35%" valign="top">
                            <asp:Panel ID="panelTDSThresholdLimit" runat="server" Width="100%">
                                <fieldset style="height: 100px;">
                                    <legend><b>TDS Treshold Limits </b></legend>
                                    <table cellpadding="2" cellspacing="0" style="margin-top: 5px;">
                                        <tr>
                                            <td style="width: 40%">
                                                Per Bill
                                            </td>
                                            <td style="width: 60%">
                                                <asp:TextBox ID="txtTDSPerBill" runat="server" CssClass="inputnumber" onkeypress="return isNumberKey(this.id,event);"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                Per Annum
                                            </td>
                                            <td>
                                                <asp:TextBox ID="txtPerAnum" runat="server" CssClass="inputnumber" onkeypress="return isNumberKey(this.id,event);"></asp:TextBox>
                                            </td>
                                        </tr>
                                    </table>
                                </fieldset>
                            </asp:Panel>
                        </td>
                        <td style="width: 55%; padding-left: 10px;" valign="top">
                            <fieldset>
                                <legend><b>Aditional Tax Applicable</b></legend>
                                <asp:GridView ID="grdAdditionalTax" Width="99%" AutoGenerateColumns="False" DataKeyNames="TAXMASTERID"
                                    runat="server" OnRowDataBound="grdAdditionalTax_OnRowDataBound">
                                    <Columns>
                                        <asp:TemplateField HeaderText="...">
                                            <ItemTemplate>
                                                <asp:CheckBox ID="chkSelect" runat="server" />
                                                <asp:HiddenField ID="hidAddTaxmasterId" runat="server" Value='<%#Eval("TAXMASTERID") %>' />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:BoundField HeaderText="Tax Type" DataField="TAXTYPE" />
                                        <asp:TemplateField HeaderText="Tax Rate">
                                            <ItemTemplate>
                                                <asp:TextBox ID="txtAdditionalTaxRate" CssClass="inputnumber" Width="95%" runat="server"
                                                    Text='<%#Eval("TAXRATE") %>'></asp:TextBox>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Ledger Name">
                                            <ItemTemplate>
                                                <asp:DropDownList ID="ddlAddTaxLedger" Width="95%" runat="server" CssClass="dropdown">
                                                </asp:DropDownList>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                </asp:GridView>
                            </fieldset>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
    <br />
    <div align="center">
        <asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" OnClientClick="return ValidateInput();"
            CssClass="button" ValidationGroup="V" />
        <asp:Button ID="btnClose" runat="server" CssClass="button" OnClientClick="return CheckValidateAddTaxLedger();"
            Text="Close" OnClick="btnClose_Click" />
    </div>
    <center>
        <asp:GridView ID="grdTaxDetails" runat="server" CssClass="gridview" AlternatingRowStyle-CssClass="gridview_alternate"
            DataKeyNames="TxDetId,TaxMasterId" EmptyDataText="No Tax Details Found..." AutoGenerateColumns="false"
            RowStyle-CssClass="gridviewitem" PagerStyle-CssClass="pgr" OnSelectedIndexChanged="grdTaxDetails_OnSelectedIndexChanged">
            <Columns>
                <asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderText="S.No.">
                    <ItemTemplate>
                        <%#Container.DataItemIndex+1 %></ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField HeaderText="Tax Type" DataField="taxtype" NullDisplayText="" />
                <asp:BoundField HeaderText="Main Class" DataField="mainclassname" NullDisplayText="" />
                <asp:BoundField HeaderText="Sub Class" DataField="subclassname" NullDisplayText="" />
                <asp:BoundField HeaderText="From Date" DataField="efffromdate" DataFormatString="{0:dd-MMM-yyyy}" />
                <asp:TemplateField HeaderText="To Date">
                    <ItemTemplate>
                        <%# string.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(Eval("efftodate"))).Replace("06/06/2079", "Till Date") %>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField HeaderText="Tax Rate" DataField="taxrate" DataFormatString="{0:0.00}"
                    NullDisplayText="0" ItemStyle-HorizontalAlign="Right" />
                <asp:BoundField HeaderText="Ledger" DataField="lname" NullDisplayText="" />
                <asp:BoundField HeaderText="Threshold/Bill" DataField="threshold" DataFormatString="{0:0.00}"
                    NullDisplayText="0" ItemStyle-HorizontalAlign="Right" />
                <asp:BoundField HeaderText="Threshold/Annum" DataField="thresholdforyear" DataFormatString="{0:0.00}"
                    NullDisplayText="0" ItemStyle-HorizontalAlign="Right" />
                <asp:CommandField HeaderText="Edit" SelectText="<img src='../../Menu/images/Edit_user.png'/>"
                    ShowHeader="True" ShowSelectButton="True" ItemStyle-HorizontalAlign="Center" />
            </Columns>
            <PagerStyle HorizontalAlign="Right" />
        </asp:GridView>
    </center>
    </form>
</body>
</html>
